<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8"/>
    <title>积分兑换-{eyou:global name='web_name' /}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
    <link href="{eyou:global name='web_cmspath'/}/favicon.ico" rel="shortcut icon" type="image/x-icon"/>
    {eyou:static file="users/skin/css/eyoucms.css" /}
    <!-- 新样式 2020-11-25 -->
    {eyou:static file="users/skin/css/element/index.css" /}
    {eyou:static file="users/skin/css/e-user.css" /}
    {eyou:include file="users/skin/css/diy_css.htm"/}

    {eyou:static file="/public/static/common/js/jquery.min.js"/}
    {eyou:static file="users/skin/js/global.js"/}
    {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
</head>

<body class="centre shop">
    <!-- 头部 -->
    {eyou:include file="users/users_header.htm" /}
    <!-- 头部结束 -->
    <div class="breadcrumbs"></div>

    <div class="ey-body-bg">
        <div class="ey-body pd0">
            <div class="ey-container w1226">
                <!-- 侧边 -->
                {eyou:include file="users/users_left.htm" /}
                <!-- 侧边结束 -->
                <!-- 中部 -->
                <div class="ey-con fr">
                    <div class="el-main main-bg xin_mian">
                        <div class="el-row shop-oper">
                            <h1 class="title">积分兑换</h1>
                        </div>
                        <div class="el-row shop-oper mt20">
                            <div class="shop-oper-bottom">
                                <div class="shop-oper-l">
                                    <div class="el-button-group">
                                        <a class="el-button-xin el-button--default first active" href="javascript:void(0);" id="a_changeGift1" onclick="changeGift(1);">全部商品</a>
                                        <a class="el-button-xin el-button--default" href="javascript:void(0);" id="a_changeGift2" onclick="changeGift(2);">兑换记录</a>
                                    </div>
                                </div>
                                <div class="shop-oper-r dpf">
                                    <div class="users-money">我的{$score_name}&nbsp;:&nbsp;<span class="red fb">{$users.scores}</span></div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="pro-list">
                            {eyou:empty name="$list"}
                                <div class="cell pt100 tc">
                                   <span class="mb10"><img id='litpic_img'  src="{eyou:static file='users/skin/images/null-data.png' /}"/></span>
                                 </div>
                            {eyou:else/}
                            <ul>
                                {eyou:volist name="$list" id="vo" key="k"}
                                <li>
                                    <div class="diva">
                                        <div class="tit">
                                            <div class="tit-l" data-url="{:url('user/Memgift/users_gift_detail',['gift_id'=>$vo.gift_id])}" onclick="goDetail(this)">
                                                <img src="{$vo.litpic}">
                                            </div>
                                            <div class="tit-r">
                                                <h2 data-url="{:url('user/Memgift/users_gift_detail',['gift_id'=>$vo.gift_id])}" onclick="goDetail(this)">{$vo.giftname}</h2>
                                                <p>{$vo.score}{$score_name}</p>
                                                {eyou:if condition='$users.scores >= $vo.score'}
                                                <p>
                                                    {eq name='$vo.type' value='-1'}
                                                    <a href="javascript:void(0)" class="okgo" data-url="{:url('user/Memgift/users_gift_shiwu',['gift_id'=>$vo.gift_id])}" onclick="jumpInfo(this)">立即兑换</a>
                                                    {else/}
                                                    <a href="javascript:void(0)" class="okgo" data-url="{:url('user/Memgift/users_gift_vip',['gift_id'=>$vo.gift_id])}" onclick="jumpVip(this)">立即兑换</a>
                                                    {/eq}
                                                </p>
                                                {eyou:else /}
                                                <p><a class="okgo nones">{$score_name}不足</a></p>
                                                {/eyou:if}
                                            </div>
                                        </div>
                                    </div>
                                </li>
                                {/eyou:volist}
                            </ul>
                            {/eyou:empty}
                        </div>
                        
                        
                        
                        
                        <!-- END -->
                        <div class="ey-con-inside mt20" style="display: none;">
                            <div id="finance-list_wrapper" class="el-table el-table--fit el-table--enable-row-hover el-table--enable-row-transition" style="width: 100%;">
                                <table class="pay_details" cellspacing="0" cellpadding="0" style="width: 100%">
                                    <thead>
                                        <tr role="row">
                                            <th class="w40">
                                                <div class="cell tc">
                                                    <span>ID</span>
                                                </div>
                                            </th>
                                            <th><div class="cell tl">商品名称</div></th>
                                            <th class="w150"><div class="cell tc">消耗({$score_name})</div></th>
                                            <th class="w200"><div class="cell tc">兑换时间</div></th>
                                            <th class="w80"><div class="cell tc">状态</div></th>
                                        </tr>
                                    </thead>
                        
                                    <tbody>
                                    {eyou:empty name="$order_list"}
                                    <tr>
                                        <td  align="center" axis="col0" colspan="50">
                                            <div class="cell pt100 tc">
                                               <span class="mb10"><img id='litpic_img'  src="{eyou:static file='users/skin/images/null-data.png' /}"/></span>
                                             </div>
                                        </td>
                                    </tr>
                                    {eyou:else/}
                                        {eyou:volist name="$order_list" id="vo"}
                                        <tr>
                                            <td>
                                                <div class="cell tc">
                                                    <span>{$vo.key}</span>
                                                </div>
                                            </td>
                                            <td>
                                                <div class="cell tl">
                                                    <a href="javascript:void(0);" class="arc-name">
                                                        <div class="arc-pic">
                                                        <img src="{$vo.litpic}">
                                                        </div>
                                                        <div class="arc-title">
                                                        {$vo.giftname}
                                                        </div>
                                                    </a>
                                                </div>
                                            </td>
                                            <td>
                                                <div class="cell tc">{$vo.score}{eyou:if condition="$vo.status eq 2"}[已返还]{/eyou:if}</div>
                                            </td>
                                            <td>
                                                <div class="cell tc">{$vo.add_time|MyDate="Y-m-d H:i",###}</div>
                                            </td>
                                            <td>
                                                <div class="cell tc">
                                                    {eyou:if condition="$vo.status eq 1"}
                                                    <span style="color: #67c23a">已发货</span>
                                                    {elseif condition="$vo.status eq 2"}
                                                    <span style="color: #F00">发货取消</span>
                                                    {else /}
                                                    <span style="color: #333">待发货</span>
                                                    {/eyou:if}
                                                </div>
                                            </td>
                                        </tr>
                                        {/eyou:volist}
                                    {/eyou:empty}
                                    </tbody>
                                </table>
                            </div>
                            {$page}
                            {eyou:if condition="!empty($pager->totalRows)"}
                            <div class="fytotal">{:sprintf(foreign_lang('page5'), $pager->totalPages, $pager->totalRows)}</div>
                            {/eyou:if}
                        </div>
                     </div>
                </div>
                <!-- 中部结束 -->
            </div>
            
        </div>

    </div>
<script>
    function changeGift(n) {
    	if (1 == n){
    	    $('#a_changeGift1').addClass('active');
    	    $('#a_changeGift2').removeClass('active');
    	    $('.pro-list').show();
    	    $('.ey-con-inside').hide();
    	} else{
            $('#a_changeGift2').addClass('active');
            $('#a_changeGift1').removeClass('active');
            $('.pro-list').hide();
            $('.ey-con-inside').show();
    	}
    }
    //兑换实物
    function jumpInfo(obj){
        var url = $(obj).data('url');
        var index = layer.open({
            type: 2,
            id: 'iframe_goinfo',
            title: '填写收货信息',
            fixed: true, //不固定
            shadeClose: false,
            shade: [0.3,'#000'],
            maxmin: false, //开启最大化最小化按钮
            closeBtn: 1,
            area: ['388px','288px'],
            content: url
        });
    }
    //打开详情页
    function goDetail(obj) {
        //iframe窗
        var url = $(obj).data('url');
        var index = layer.open({
            type: 2,
            id: 'iframe_goDetail',
            title: '商品详情',
            fixed: true, //不固定
            shadeClose: false,
            shade: [0.3, '#000'],
            maxmin: false, //开启最大化最小化按钮
            closeBtn: 1,
            area: ['700px', '99%'],
            content: url,
        });
    }
    //兑换会员
    function jumpVip(obj) {
        var url = $(obj).data('url');
        layer.confirm('确定要兑换商品？', {
            title: false,
            closeBtn: false
        }, function() {
            $.ajax({
                url: url,
                type: 'POST',
                dataType: 'JSON',
                data: {
                    long: 0
                },
                success: function(res) {
                    if (1 == res.code) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            window.location.reload();
                        });
                    } else if (res.code == 2) {
                        layer.confirm(res.msg, {
                            btn: ['继续兑换', '取消'] //按钮
                        }, function() {
                            $.ajax({
                                url: url,
                                type: 'POST',
                                dataType: 'JSON',
                                data: {
                                    long: 1
                                },
                                success: function(res) {
                                    if (1 == res.code) {
                                        layer.msg(res.msg, {
                                            icon: 1,
                                            time: 1000
                                        }, function() {
                                            window.location.reload();
                                        });
                                    } else {
                                        layer.msg(res.msg, {
                                            icon: 2,
                                            time: 2000
                                        });
                                    }
                                },
                                error: function(e) {
                                    layer.closeAll();
                                    layer.alert(e.responseText, {
                                        icon: 5,
                                        title: false
                                    });
                                }
                            })
                        });
                    } else {
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 2000
                        });
                    }
                },
                error: function(e) {
                    layer.closeAll();
                    layer.alert(e.responseText, {
                        icon: 5,
                        title: false
                    });
                }
            })
        }, function(index) {
            layer.closeAll(index);
        });
    }
</script>
{eyou:include file="users/users_footer.htm" /}